package com.yc.yyds.servlet;

import com.google.gson.Gson;
import com.yc.yyds.dao.LinkDao;
import com.yc.yyds.Bean.Result;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "RemoveLinkServlet", value = "/RemoveLinkServlet.s")
public class RemoveLinkServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        LinkDao dao = new LinkDao();
        String linkid = request.getParameter("linkid");
        String flag = request.getParameter("flag");
        if ("逻辑删除".equals(flag)) {
            dao.remove1(linkid);
        }else {
            dao.remove(linkid);
        }
        String s = new Gson().toJson(new Result(1, "删除成功", null));
        response.getWriter().append(s);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
